// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

.account-edit-entry {
  @top: account-edit-entry;

  @section-width: 250px;
  @label-width: 160px;
  @input-width: 250px;
  @input-width-wide: 100%;

  text-transform: none;
  padding: 10px 0;
  margin: 0;

  display: flex;
  align-items: center;
  flex-wrap: wrap;

  &--block {
    display: block;

    @media @desktop {
      padding-left: @label-width;
    }
  }

  &--no-label {
    @media @desktop {
      padding-left: @label-width;
    }
  }

  &.js-account-edit-avatar--start {
    position: relative;

    // placeholder to prevent triggering dragleave when entring child element
    &::after {
      .full-size();
      content: "";
    }
  }

  &__avatar {
    .default-border-radius();
    .own-layer();
    width: @avatar-size--base;
    height: @avatar-size--base;
    margin-bottom: 10px;
    overflow: hidden;
  }

  &__button {
    margin-left: 10px;

    @media @mobile {
      margin-left: 5px;
    }
  }

  &__checkbox {
    margin: 0;
    cursor: pointer;
    text-transform: inherit;

    display: flex;
    flex-wrap: wrap;
    align-items: baseline;

    @media @desktop {
      position: relative;
      flex-wrap: nowrap;
    }

    &--grid {
      display: flex;
      justify-content: center;
    }

    &--no-wrap {
      flex-wrap: nowrap;
    }
  }

  &__checkbox-label {
    margin-bottom: 5px;
    width: 100%;
    order: -1;
    // label is 600, but checkbox-label isn't in a label when in a grid.
    font-weight: 600;

    &--grid {
      margin-bottom: 0;
      order: 0;
    }

    @media @desktop {
      margin-bottom: 0;
      width: auto;
      order: 0;
    }
  }

  &__checkbox-label-info {
    margin-top: 5px;
    font-weight: normal;
    display: block;
  }

  &__checkbox-status {
    pointer-events: none;
    display: flex;
    align-items: baseline;
    width: max-content;

    @media @desktop {
      position: absolute;
      right: 100%;
      height: 100%;
    }
  }

  &__checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;

    @media @desktop {
      position: relative;
    }

    &--grid {
      display: grid;
      grid-template-columns: auto auto;
    }

    &--vertical {
      flex-direction: column;
    }
  }

  &__checkboxes-label {
    margin-bottom: 10px;
    width: 100%;
  }

  &__rules {
    margin-top: 10px;
  }

  &__drop-overlay {
    .full-size();
    .center-content();
    text-align: center;
    padding: 10px;
    opacity: 0;
    color: #fff;
    background-color: rgba(0, 0, 0, var(--bg-opacity));
    transition: all 120ms;
    --bg-opacity: 0;

    .@{top}.js-account-edit-avatar--start & {
      opacity: 1;
      --bg-opacity: 0.5;
    }

    // higher priority than --start
    .@{top}.js-account-edit-avatar--hover & {
      --bg-opacity: 0.7;
    }
  }

  &__error {
    display: none;
    margin-top: 5px;
    width: 100%;
    color: @osu-colour-h1;
    padding-left: 10px;

    @media @desktop {
      padding-left: (@label-width + 10px);
    }

    .@{top}[data-form-error-state="error"] & {
      display: block;
    }
  }

  &__delivery-options {
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-gap: 5px;
  }

  &__group {
    flex: 1;
  }

  &__input {
    .reset-input();
    .default-border-radius();

    flex: 1;
    max-width: @input-width;
    align-self: stretch;
    background-color: @osu-colour-b3;
    border: 2px solid transparent;
    color: #fff;
    font-weight: normal;
    padding: 5px;

    @media @mobile {
      font-size: @font-size--phone-input;
    }

    .@{top}--read-only & {
      background: none;
    }

    &:focus {
      border-color: @osu-colour-l1;
    }

    .@{top}[data-form-error-state="error"] & {
      border-color: @red;
    }

    .@{top}--wide & {
      max-width: @input-width-wide;
    }
  }

  &__label {
    width: 100%;
    flex: none;
    padding-bottom: 5px;
    order: -1;
    font-weight: bold;
    color: @osu-colour-f1;

    @media @desktop {
      align-self: center;
      width: @label-width;
      padding-right: 10px;
      padding-bottom: 0;
      text-align: right;
    }

    &--top-pinned {
      align-self: flex-start;
    }

    *:focus ~ & {
      color: @osu-colour-l1;
    }
  }

  &__misc-info {
    max-width: @input-width;
    display: block;

    &--signature-preview {
      max-height: @forum-signature-height;
      overflow: hidden;
    }

    .@{top}--wide & {
      max-width: @input-width-wide;
    }
  }

  &__overlay-spinner {
    .full-size();
    .center-content();

    background-color: fade(#000, 75%);
    opacity: 0;
    transition: all 120ms;

    .@{top}.js-account-edit-avatar--saving & {
      opacity: 1;
    }
  }
}
